package com.dongchedi.utils.constant;

/**
 * @author leibidong
 * @description 商品的颜色
 * @date 2021/6/25
 */
public enum ColorConstant {
    RED("红色", 1),YELLO("黄色", 2),
    HEIHUI("黑灰色", 3),BACK("黑色", 4),
    XIANGYABAI("象牙白",5),XINGKONGBAN("星空版",6),
    MOXIGELV("墨西哥绿",7),HAILANGBAN("海浪版",8),
    HUNDONGHONG("魂动红",9),HAOHANXINGKONGLAN("浩瀚星空蓝",10),
    WUGUANGSHISHEBAI("五光十色白",11),WUCAIBANLANHEI("五彩斑斓黑",12),
    CPU("这是很长很长的一个cpu",13),MAYIYAHEI("蚂蚁牙黑",14);
    //1、'红色',2、'黄色',3、'黑灰色',4、'黑色',5、'象牙白',6、'星空版',7、'墨西哥绿',8、'海浪版',
    // 9、'魂动红',10、'浩瀚星空蓝',11、'五光十色白',12、'五彩斑斓黑',13、'这是很长很长的一个cpu',14、'蚂蚁牙黑'
    private String name ;
    private int index ;
    private ColorConstant( String name , int index ){
        this.name = name ;
        this.index = index ;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getIndex() {
        return index;
    }
    public void setIndex(int index) {
        this.index = index;
    }
    public int getIndexByName(String name){
        for (ColorConstant colorConstant:ColorConstant.values()){
            if(colorConstant.getName().equals(name))
                return colorConstant.getIndex();
        }
        return 3;
    }
    public String getNameByIndex(Integer index){
        for (ColorConstant colorConstant:ColorConstant.values()){
            if(colorConstant.getIndex()==index)
                return colorConstant.getName();
        }
        return "黑灰色";
    }
}
